package org.lanqiao.threads.imp1;

public class ThreadC implements Runnable {
	//属性
			private ThreadA thA;
			
				
	public ThreadC(ThreadA thA) {
		super();
		this.thA = thA;
	}


	@Override
	public void run() {
		//多线程的业务逻辑
		//循环次数
		int num =20;
		// 循环打印1-20
		for (int i=0;i<20;i++){
			System.out.println("ThreadB:"+i);
			//休眠0.5秒
			try {
				Thread.sleep(300);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			//打印到一半的时候，调用线程A
			if(i==num/2){
				//召唤子线程A
				//使用start方法启动多线程
				thA.start();
				try {
					thA.join();
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		}
		
	
}			


